<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>产品分类列表</title>
		<link rel="stylesheet" href="/css/modules.css" type="text/css"
			media="screen" />
		<link rel="stylesheet" href="/css/modules1.css" type="text/css"
			media="screen" />
		<link rel="stylesheet" href="/css/jquery-ui.css" type="text/css"
			media="screen" />
		<link rel="stylesheet" href="/css/jquery.wysiwyg.css" type="text/css"
			media="screen" />
		<script type='text/javascript' src="/js/jquery-1.4.2.min.js"></script>
		<script type='text/javascript' src="/js/jquery.js"></script>
		<script type='text/javascript' src="/js/jquery-ui.js"></script>
		<script type='text/javascript' src="/js/jquery.wysiwyg.js"></script>
		<script type='text/javascript' src="/js/custom.js"></script>
		<script type='text/javascript'>
	function addCategory() {
		jQuery("#addCategory").dialog();
		jQuery("#addCategory").dialog("open");
	}
	function editCategory(f) {
		var name=$(f).parent().prev().prev().html();
		var remark=$(f).parent().prev().html();
		var cid=$(":input[name='cid']").val();
		if(remark.indexOf("&nbsp;")>0){
		$("#editCategory :input[name='remark']").val(remark);
		}
		$("#editCategory :input[name='name']").val(name);
		$("#editCategory :input[name='id']").val(cid);
		jQuery("#editCategory").dialog();
		jQuery("#editCategory").dialog("open");
		
	}
	function closeDialog(){
		if(jQuery("#editCategory").dialog("isOpen")){
			jQuery("#editCategory").dialog("close");
		}
		if(jQuery("#addCategory").dialog("isOpen")){
			jQuery("#addCategory").dialog("close");
		}
	}
</script>
	</head>

	<body style="background-color: transparent">
		<div style="padding: 10px;">
			<h2 class="jquery_tab_title">
				产品分类列表
			</h2>
			<input type="button" style="margin: 10px;" value="+新建分类"
				class="button" onclick="addCategory();"	/>
		</div>
		<div>
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<th class="th_first">
						&nbsp;
					</th>
					<th>
						名称
					</th>
					<th>
						备注
					</th>
					<th>
						操作
					</th>
				</tr>
				<s:iterator value="categoryList">
					<tr>
						<td class="td_first">
							<input type="checkbox" />
						</td>
						<td>${name }</td>
						<td>&nbsp;${remark }</td>
						<td>
							<input type="hidden" name="cid" value="${id }" />
							<a href="##" onclick="editCategory(this);">编辑</a>/
							<a href="/CategoryAction!del.action?id=${id }" onclick="return confirm('确定将此记录删除?')">删除</a>
						</td>
					</tr>
				</s:iterator>
			</table>
		</div>
		<div style="padding: 10px;">
			<span style="float: left"> 
				<!-- 
					<input type="button" value="选中全部" class="button" />
   					<input type="button" value="批量操作" class="button"/>
				--> 
			</span>
			<span style="float: right"> 
				<s:property	value="#request.pagination" escape="false" /> 
			</span>
		</div>

		<!-- 	新建分类dialog	 -->
		<div id="addCategory" style="display: none;" title="新建分类">
			<form action="CategoryAction!add.action" method="post">
				<p>
					<label>
						分类名称:
					</label>
					<input type="text" name="name" class="input-small" />
				</p>
				<p>
					<label>
						备注:
					</label>
					<input type="text" name="remark" class="input-medium"/>
				</p>
				<p>
					<input type="submit" value="确定" class="button" />
					<input type="button" value="取消" class="button" onclick="closeDialog();"/>
				</p>
			</form>
		</div>

		<!-- 	编辑分类dialog	 -->
		<div id="editCategory" style="display: none;" title="编辑分类">
			<form action="CategoryAction!update.action" method="post">
				<p>
					<label>
						分类名称:
					</label>
					<input type="text" name="name" class="input-small" value="" />
				</p>
				<p>
					<label>
						备注:
					</label>
					<input type="text" name="remark" class="input-medium" value="" />
				</p>
				<p>
					<input type="hidden" name="id" />
					<input type="submit" value="确定" class="button" />
					<input type="button" value="取消" class="button" onclick="closeDialog();"/>
				</p>
			</form>
		</div>
	</body>
</html>
